-
Notifications
You must be signed in to change notification settings - Fork 269
Fix Language foreign key column lengths #5623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
And... of course I should have rerun the tests after rebasing... |
When Language.id was changed from max_length=7 to max_length=14 in migration 0081, Django 1.9 did not cascade the primary key column size change to foreign key and many-to-many junction table columns. This migration fixes those columns for databases that were created before the migration squash. It is idempotent - columns that are already varchar(14) are not modified. Fixes: contentcuration_channel.language_id Fixes: contentcuration_channel_included_languages.language_id Fixes: contentcuration_contentnode.language_id Fixes: contentcuration_file.language_id Adds migration test that deliberately corrupts the DB columns then runs the migration and confirms the fix.
bjester
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only column that is still limited to 7 characters is contentcuration_channel_included_languages.language_id. This makes sense because that's where the error occurred, and if a channel already included content for a language that exceeded the limit, that means a content node and file must already have it. I've confirmed, on every cloud instance DB, the aforementioned column is the only column named language_id that is less than 14 characters limit.
After verification on production servers, only the contentcuration_channel_included_languages junction table is affected by the varchar(7) issue. The other FK columns (channel.language_id, contentnode.language_id, file.language_id) are already varchar(14). This simplifies the migration to only fix the one affected column. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Have updated with a follow up commit to narrow the scope here - left it as a follow up commit to make review easier, but we can squash merge this, as the first commit is not needed! |
bjester
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and verified. LGTM ![]()
Summary
When Language.id was changed from max_length=7 to max_length=14 in migration 0081, Django 1.9 did not cascade the primary key column size change to many-to-many junction table columns.
This migration fixes the included_languages through table language_id column for databases that were created before the migration squash. It is idempotent - columns that are already varchar(14) are not modified.
Fixes: contentcuration_channel_included_languages.language_id
Adds migration test that deliberately corrupts the DB columns then runs the migration and confirms the fix.
References
Fixes #5618
Reviewer guidance
Because of our migration squashing, the bug is not extant on development machines, so coercing the database column length manually and then running the migration to ensure the change in the migration test was the best I could do here.
🤖 This was created by Claude Code. @rtibbles then reviewed the generated output, and made updates before making it ready for review 🤖